<?php

class Module {

    private $mId;
    private $mName;
    private $mSequence;
    private $mIcon;
    private $mIsEnabled;
    private $mIsShow;
    private $mIsLoaded;
    
    private $mFunctionList;

    public function getId() {
        return $this->mId;
    }

    public function setId($value) {
        $this->mId = $value;
    }

    public function getName() {
        return $this->mName;
    }

    public function setName($value) {
        $this->mName = $value;
    }

    public function getSequence() {
        return $this->mSequence;
    }

    public function setSequence($value) {
        $this->mSequence = $value;
    }

    public function getIcon() {
        return $this->mIcon;
    }

    public function setIcon($value) {
        $this->mIcon = $value;
    }

    public function getIsEnabled() {
        return $this->mIsEnabled;
    }

    public function setIsEnabled($value) {
        $this->mIsEnabled = $value;
    }

    public function getIsShow() {
        return $this->mIsShow;
    }

    public function setIsShow($value) {
        $this->mIsShow = $value;
    }

    public function IsLoaded(){
        return $this->mIsLoaded;
    }
    
    public function setIsLoaded($value) {
        $this->mIsLoaded = $value;
    }
    
    public function getFunctionList(){
        if (($this->mFunctionList == null) && ($this->mId!=null)) {
                $FunctionsService = new FunctionsService();
                $this->mFunctionList = $FunctionsService->getListByModule($this->mId);
                if ($this->mFunctionList != null) {
                    foreach($this->mFunctionList as $item){
                        $item->setModule($this);
                    }
                }
            }
        return $this->mFunctionList;
    }
    
    public function setFunctionList($value){
        $this->mFunctionList = $value;
        if($this->mFunctionList!=null){
            foreach($this->mFunctionList as $item){
                $item->setModule($this);
            }
        }
    }
    
    public function toArray(){
        $model = array(
            'id' => $this->mId,
            'name' => $this->mName,
            'icon' => $this->mIcon,
            'sequence' => $this->mSequence,
            'is_enabled' => $this->mIsEnabled,
            'is_show' => $this->mIsShow,
        );
        
        return $model;
    }
    
}
